<template>
  <div class="header">
    <van-icon class="icon" color="#2B95EF" size="4vw" name="arrow-left"  @click="toBack">
      <!--      title放在icon标签里-->
      <span style="color: #141414; margin-left: 8px;">{{ title }}</span>
    </van-icon>
    <!--    显示课表周数，timeTable组件传，该插槽非必传-->
    <slot name="timeTableWeekSlot"></slot>
    <nut-icon class="icon-shua" size="4vw" name="refresh" @click="reload"></nut-icon>
  </div>
</template>

<script>
import {useRouter} from 'vue-router';
export default {
  props: ['title'],

  setup() {

    const router = useRouter();
    // const store = useStore();

    const toBack = (event) => {
      event.stopPropagation(); // 阻止事件冒泡
      router.back();
    }

    const reload = (event) => {
      event.stopPropagation(); // 阻止事件冒泡
      window.location.reload();
    }

    // const handleEdit = () => {
    //     if(store.state.cartList.length){
    //         store.commit('changeEdit');
    //         store.commit('changeDelete');
    //     }else{
    //         Toast.fail('请添加菜品到购物车！');
    //     }
    // };

    return {
      // store,
      toBack,
      reload
      // handleEdit
    }

  }

}
</script>

<style lang="less" scoped>
.header {
  background-color: #fff;
  height: 80px;
  display: flex;
  font-size: 35px;
  justify-content: center;
  align-items: center;
  color: #141414;
  margin-bottom: 10px;

  .icon {
    position: absolute;
    left: 30px;
  }

  .icon-shua {
    position: absolute;
    right: 30px;
    color: #2B95EF;
  }
}
</style>
